//package com.icangya.admin;
//import org.springframework.web.bind.annotation.*;
//
//
//@CrossOrigin
//@RestController
//@RequestMapping(path = "/foot/user/")
//public class UserFootController {
//
//    @Autowired
//    private IFootUserService iUserService;
//
//    @Autowired
//    private  IAdminUserService iAdminUserService;
//    @Autowired
//     private  IMoneyService iMoneyService;
//    @Autowired
//    private IDomainService iDomainService;
//    @Autowired
//    private IFbWxSuitcaseService iFbWxSuitcaseService;
//    @Autowired
//    private IBadUserService iBadUserService;
//
//    @Autowired
//    private ICashRegisterDAO iCashRegisterDAO;
//
//    private  Logger logger = LoggerFactory.getLogger(this.getClass());
//
//
//    /**
//     * 测试用户是否非法登录游戏
//     * @param uid
//     * @param session
//     * @param request
//     * @param response
//     * @throws IOException
//     */
//    @RequestMapping(value = "loginGame")
//    public void loginGame(@RequestParam Long uid,@RequestParam String cy_key,HttpSession session, HttpServletRequest request,
//                          HttpServletResponse response) throws Exception {
//
//        String str = "uid=" + uid + "&cy_key=" + StaticValue.SIGN_KEY;//正确的明文
//        str = DigestUtils.md5DigestAsHex(str.getBytes("UTF-8"));//第一次md5加密
//        String md5Str = DigestUtils.md5DigestAsHex(str.getBytes("UTF-8"));//第二次md5加密
//        cy_key = DESUtil.getIstance().decrypt(cy_key, StaticValue.SIGN_KEY).trim();//DES解密 用key
//        logger.info(md5Str + "===" + cy_key);
//        if (md5Str.equals(cy_key)) {//通过
//            User user = iUserService.getUserByUid(uid);
//            //request.getSession().setAttribute("Football",user.getOpenId());
//            session.removeAttribute(FootBall.FOOT_USER_SESSION);
//            session.setAttribute(FootBall.FOOT_USER_SESSION, user);//将登录的用户信息注册进session中
//
//            StringBuffer url = request.getRequestURL();
//            String tempContextUrl = url.delete(url.length() - request.getRequestURI().length(), url.length()).append
//                    (request.getServletContext().getContextPath()).append("/").toString();
////            response.sendRedirect(tempContextUrl + "footballgame/index.html");//Football.html //跳转到我们的游戏界面  足球小将
////            response.sendRedirect("http://"+iDomainService.getDoamin().get(0).getDomainUrl() + "/slyderAdventures/index.html");//Football.html //跳转到我们的游戏界面  足球小将
//            response.sendRedirect(StaticValue.WX.BASE_URL + "/m/index.html");
//
//        }else{
//            logger.info("校验错误!");
//            response.sendRedirect(StaticValue.WX.NO_URL);//非法登录
//        }
//    }
//
//
//
//    /**
//     * 用户的用户详情
//     * @return
//     */
//    @RequestMapping(value = "getUserOpenId")
//    public JSONObject selectUserByOpnId(HttpSession session){
//        User user= getTestUser(session);
//       String openId=user.getOpenId();
//        JSONObject jsonObject=iUserService.selectUserByOpnId(openId);
//        return JSONUtils.getRoot(0,"success",jsonObject);
//    }
//
//    /**
//     * 用户的团队详情
//     * @return
//     */
//    @RequestMapping(value = "getProxyNum")
//    public JSONObject getProxyNum(HttpSession session){
//        User user= getTestUser(session);
//        JSONObject jsonObject=iUserService.getProxyNum(user.getId());
//        return JSONUtils.getRoot(0,"success",jsonObject);
//    }
//
//    /**
//     * 拉黑投诉的用户
//     * @return
//     */
//    @RequestMapping(value = "setBadUser")
//    public JSONObject setBadUser(HttpSession session){
//        User user= getTestUser(session);
//        //String openId, String reson, Timestamp createTime
//        BadUserDO badUserDO=new BadUserDO(user.getOpenId(),"恶意投诉",new Timestamp(new Date().getTime()));
//        iUserService.saveBadUser(badUserDO);
//        return JSONUtils.getRoot(0,"success","");
//    }
//    /**
//     * 获取用户信息
//     * @param session
//     * @return
//     */
////    @RequestMapping(value = "getUserMessage")
////    public JSONObject getUserMessage(HttpSession session){
////package com.icangya.admin;
////
////import com.alibaba.fastjson.JSONArray;
////import com.alibaba.fastjson.JSONObject;
////import com.icangya.DAO.ICashRegisterDAO;
////import com.icangya.DAO.ICommissionFootDAO;
////import com.icangya.Utils.*;
////import com.icangya.Value.FootBall;
////import com.icangya.Value.StaticValue;
////import com.icangya.domain.*;
////import com.icangya.service.*;
////import com.icangya.weixin.sdk.WXPayUtil;
////import com.icangya.wxpay.utils.HttpUtils;
////import com.icangya.wxpay.utils.PayUtil;
////import com.icangya.wxpay.utils.XmlUtil;
////import org.slf4j.Logger;
////import org.slf4j.LoggerFactory;
////import org.springframework.beans.factory.annotation.Autowired;
////import org.springframework.util.DigestUtils;
////import org.springframework.web.bind.annotation.*;
////import sun.misc.BASE64Decoder;
////
////import javax.servlet.http.HttpServletRequest;
////import javax.servlet.http.HttpServletResponse;
////import javax.servlet.http.HttpSession;
////import java.io.*;
////import java.sql.Timestamp;
////import java.util.*;
////import java.util.regex.Pattern;
////
////import static com.icangya.Value.Error_Code.SUCCESS;
////
////@CrossOrigin
////@RestController
////@RequestMapping(path = "/foot/user/")
////public class UserFootController {
////
////    @Autowired
////    private IFootUserService iUserService;
////
////    @Autowired
////    private  IAdminUserService iAdminUserService;
////    @Autowired
////     private  IMoneyService iMoneyService;
////    @Autowired
////    private IDomainService iDomainService;
////    @Autowired
////    private IFbWxSuitcaseService iFbWxSuitcaseService;
////    @Autowired
////    private IBadUserService iBadUserService;
////
////    @Autowired
////    private ICashRegisterDAO iCashRegisterDAO;
////
////    private  Logger logger = LoggerFactory.getLogger(this.getClass());
////
////
////    /**
////     * 测试用户是否非法登录游戏
////     * @param uid
////     * @param session
////     * @param request
////     * @param response
////     * @throws IOException
////     */
////    @RequestMapping(value = "loginGame")
////    public void loginGame(@RequestParam Long uid,@RequestParam String cy_key,HttpSession session, HttpServletRequest request,
////                          HttpServletResponse response) throws Exception {
////
////        String str = "uid=" + uid + "&cy_key=" + StaticValue.SIGN_KEY;//正确的明文
////        str = DigestUtils.md5DigestAsHex(str.getBytes("UTF-8"));//第一次md5加密
////        String md5Str = DigestUtils.md5DigestAsHex(str.getBytes("UTF-8"));//第二次md5加密
////        cy_key = DESUtil.getIstance().decrypt(cy_key, StaticValue.SIGN_KEY).trim();//DES解密 用key
////        logger.info(md5Str + "===" + cy_key);
////        if (md5Str.equals(cy_key)) {//通过
////            User user = iUserService.getUserByUid(uid);
////            //request.getSession().setAttribute("Football",user.getOpenId());
////            session.removeAttribute(FootBall.FOOT_USER_SESSION);
////            session.setAttribute(FootBall.FOOT_USER_SESSION, user);//将登录的用户信息注册进session中
////
////            StringBuffer url = request.getRequestURL();
////            String tempContextUrl = url.delete(url.length() - request.getRequestURI().length(), url.length()).append
////                    (request.getServletContext().getContextPath()).append("/").toString();
//////            response.sendRedirect(tempContextUrl + "footballgame/index.html");//Football.html //跳转到我们的游戏界面  足球小将
//////            response.sendRedirect("http://"+iDomainService.getDoamin().get(0).getDomainUrl() + "/slyderAdventures/index.html");//Football.html //跳转到我们的游戏界面  足球小将
////            response.sendRedirect(StaticValue.WX.BASE_URL + "/m/index.html");
////
////        }else{
////            logger.info("校验错误!");
////            response.sendRedirect(StaticValue.WX.NO_URL);//非法登录
////        }
////    }
////
////
////
////    /**
////     * 用户的用户详情
////     * @return
////     */
////    @RequestMapping(value = "getUserOpenId")
////    public JSONObject selectUserByOpnId(HttpSession session){
////        User user= getTestUser(session);
////       String openId=user.getOpenId();
////        JSONObject jsonObject=iUserService.selectUserByOpnId(openId);
////        return JSONUtils.getRoot(0,"success",jsonObject);
////    }
//
//
//    /**
//     * 获取用户的佣金记录
//     * @param session
//     * @return
//     */
//    @RequestMapping(value = "getCommissionRecord")
//    public JSONObject getCommissionRecord(HttpSession session){
//        User user=getTestUser(session);
//        String openId=user.getOpenId();
//
//        JSONObject jsonObject=   iMoneyService.getCommRecordByType(openId,"好友奖励");
//        if(jsonObject==null)
//            return JSONUtils.getRoot(1,"fail","该用户没有佣金记录");
//        return JSONUtils.getRoot(0,"success",jsonObject);
//
//    }
//
////    //获取用户转盘记录
////    @RequestMapping(value = "getTurntableRecord")
////    public JSONObject getTurntableRecord(HttpSession session){
////        User user=getTestUser(session);
////        String openId=user.getOpenId();
////
////        List<FbTurntableRecord> list=  iMissionService.getTurntableRecordByOpenId(openId);
////        if(list!=null){
////            return JSONUtils.getRoot(0,"success",list);
////        }
////        return JSONUtils.getRoot(1,"fail","该用户没有中奖明细");
////
////    }
//    //获取用户提现次数
//    @RequestMapping(value = "cashMoneyCount")
//    public JSONObject cashMoneyCount(HttpSession session){
//        User user=getTestUser(session);
//
//       double count=  iUserService.cashMoneyCount(user.getOpenId());
//            return JSONUtils.getRoot(0,"success",3-count);
//
//
//    }
//    /**
//     * 获取用户信息
//     * @return
//     */
////    @RequestMapping(value = "getUserMessage")
////    public JSONObject getUserMessage(HttpSession session){
////
////        User user=(User)session.getAttribute(FootBall.FOOT_USER_SESSION);
////        String openId=user.getOpenId();
////      return JSONUtils.getRoot(0,"success", iUserService.getUserMessage(openId)) ;
////    }
//
//
//
//
//
//    public static String convertStreamToString(InputStream is) {
//        /*
//          * To convert the InputStream to String we use the BufferedReader.readLine()
//          * method. We iterate until the BufferedReader return null which means
//          * there's no more data to read. Each line will appended to a StringBuilder
//          * and returned as String.
//          */
//        BufferedReader reader = new BufferedReader(new InputStreamReader(is));
//        StringBuilder sb = new StringBuilder();
//
//        String line = null;
//        try {
//            while ((line = reader.readLine()) != null) {
//                sb.append(line + "\n");
//            }
//        } catch (IOException e) {
//            e.printStackTrace();
//        } finally {
//            try {
//                is.close();
//            } catch (IOException e) {
//                e.printStackTrace();
//            }
//        }
//        return sb.toString();
//    }
//    /**
//     * 大转盘支付回调函数
//     * @param request
//     * @return
//     */
//    @RequestMapping(value = "/weixinpay/callback",method = RequestMethod.POST)
//    public String callBack(HttpServletRequest request){
//
//
//        logger.info("********************************   大转盘支付回调函数    *********************************");
//        logger.info("********************************   大转盘支付回调函数    *********************************");
//        logger.info("********************************   大转盘支付回调函数    *********************************");
//        InputStream is = null;
//        try {
//            is = request.getInputStream();
//        } catch (IOException e) {
//            e.printStackTrace();
//        }
//        String payreturn =  convertStreamToString(is);
//        System.out.println(payreturn);
//        JSONObject strjson = JSONObject.parseObject(payreturn);
//        String code = strjson.getString("code");
//        String msg = strjson.getString("msg");
//        JSONObject datajson = strjson.getJSONObject("data");
//        String result_code = datajson.getString("result_code");
//        String out_trade_id = datajson.getString("out_trade_id");
//        String openid = datajson.getString("openid");
//        String ch_trade_id = datajson.getString("ch_trade_id");
////        String sub_appid =  datajson.getString("sub_appid");
////        String sub_openid = datajson.getString("sub_openid");
//        String is_subscribe = datajson.getString("is_subscribe");
//        String bank_type = datajson.getString("bank_type");
//        String total_fee = datajson.getString("total_fee");
//        String fee_type = datajson.getString("fee_type");
//        String trade_state = datajson.getString("trade_state");
//        String trade_info = datajson.getString("trade_info");
//        String trade_id = datajson.getString("trade_id");
//        String mch_trade_id = datajson.getString("mch_trade_id");
//        String merchant_id = datajson.getString("merchant_id");
//        String pay_type = datajson.getString("pay_type");
//        String nonce_str = datajson.getString("nonce_str");
//
//        FbPayInfo fbPayInfo =   iFbWxSuitcaseService.getPayInfoByMchTradeId(mch_trade_id);
//        fbPayInfo.setBank_type(bank_type);
//        fbPayInfo.setCh_trade_id(ch_trade_id);
//        fbPayInfo.setCode(code);
//        fbPayInfo.setFee_type(fee_type);
//        fbPayInfo.setIs_subscribe(is_subscribe);
////        fbPayInfo.setMch_trade_id(mch_trade_id);
////        fbPayInfo.setMerchant_id(merchant_id);
//        fbPayInfo.setMsg(msg);
//        fbPayInfo.setNonce_str(nonce_str);
////        fbPayInfo.setOpenid(openid);
//        fbPayInfo.setOut_trade_id(out_trade_id);
////        fbPayInfo.setPay_type(pay_type);
//        fbPayInfo.setResult_code(result_code);
//        fbPayInfo.setTotal_fee(total_fee);
//        fbPayInfo.setTrade_id(trade_id);
//        fbPayInfo.setTrade_info(trade_info);
//        fbPayInfo.setTrade_state(trade_state);
//
//        long myid = iFbWxSuitcaseService.savePayInfo(fbPayInfo);
////        String xml = inputStream2String(is, "UTF-8");
////        logger.info(xml);
////        Map<String,String> map  = XMLBeanUtils.readStringXmlOut(xml);
////        String resultCode = map.get("result_code");
////        String returnCode = map.get("return_code");
////        String openid = map.get("openid");
////        String cashFee = map.get("cash_fee");
////        logger.info("==resultCode=="+resultCode + "==returnCode=="+ returnCode +"==openid==" + openid + "==cashFee=="+cashFee);
//
//        iFbWxSuitcaseService.updatePayinfo(fbPayInfo);
//        if("0".equals(code) && "0".equals(result_code)){
//            setBalanceMoney(fbPayInfo.getOpenid(), Double.parseDouble(total_fee)/100);
//        }
//
//        return "success";
//
//
//        /**
//         * 后面把xml转成Map根据数据作逻辑处理
//         */
////        return xml;
//    }
//    /**
//     * 游戏币支付回调
//     * @param request
//     * @return
//     */
////    @RequestMapping(value = "/weixinpay/callback",method = RequestMethod.POST)
////    public String callBack(HttpServletRequest request){
////        logger.info("********************************   游戏币支付回调    *********************************");
////        InputStream is = null;
////        try {
////            is = request.getInputStream();
////        } catch (IOException e) {
////            e.printStackTrace();
////        }
////        String xml = inputStream2String(is, "UTF-8");
////        logger.info(xml);
////        Map<String,String> map  = XMLBeanUtils.readStringXmlOut(xml);
////        String resultCode = map.get("result_code");
////        String returnCode = map.get("return_code");
////        String openid = map.get("openid");
////        String cashFee = map.get("cash_fee");
////        logger.info("==resultCode=="+resultCode + "==returnCode=="+ returnCode +"==openid==" + openid + "==cashFee=="+cashFee);
////        int gitMoney = 0;
////        switch(cashFee)
////
////        {
////
////            case "500":
////
////                gitMoney = 1;
////
////                break;
////
////            case "1000":
////
////                gitMoney = 2;
////
////                break;
////
////            case "5000":
////
////                gitMoney = 5;
////
////                break;
////
////            case "50000":
////
////                gitMoney = 50;
////
////                break;
////
////            case "100000":
////
////                gitMoney = 100;
////
////                break;
////
////            case "200000":
////
////                gitMoney = 200;
////
////                break;
////
////            default:
////
////                gitMoney = 0;
////
////                break;
////
////        }
////        if("SUCCESS".equals(resultCode) && "SUCCESS".equals(returnCode)){
////
////            setBalanceMoney(openid, Double.parseDouble(cashFee)/100,gitMoney);
////
////        }
////
////
////
////        /**
////         * 后面把xml转成Map根据数据作逻辑处理
////         */
////        return xml;
////    }
//
//
//    /**
//     * 订单支付回调
//     * @param request
//     * @return
//     */
////    @RequestMapping(value = "/weixinpay/ordercallback",method = RequestMethod.POST)
////    public String ordercallback(HttpServletRequest request){
////        logger.info("********************************   订单支付回调    *********************************");
////        InputStream is = null;
////        try {
////            is = request.getInputStream();
////        } catch (IOException e) {
////            e.printStackTrace();
////        }
////        String xml = inputStream2String(is, "UTF-8");
////        logger.info(xml);
////        Map<String,String> map  = XMLBeanUtils.readStringXmlOut(xml);
////        String resultCode = map.get("result_code");
////        String returnCode = map.get("return_code");
////        String openid = map.get("openid");
////        String cashFee = map.get("cash_fee");
////        String is_subscribe =  map.get("is_subscribe");
////        String transaction_id =  map.get("transaction_id");
////        String sign =  map.get("sign");
////        String time_end =  map.get("time_end");
////        String bank_type =  map.get("bank_type");
////        String out_trade_no =  map.get("out_trade_no");
////
////        logger.info("==resultCode=="+resultCode + "==returnCode=="+ returnCode +"==openid==" + openid + "==cashFee=="+cashFee);
////        if("SUCCESS".equals(resultCode) && "SUCCESS".equals(returnCode)){
////
////
////
//////            logger.info("===========更新订单支付状态=="+boo+"========");
//////            setBalanceMoney(openid, Double.parseDouble(cashFee)/100,gitMoney);
////
////        }
////        /**
////         * 后面把xml转成Map根据数据作逻辑处理
////         */
////        return xml;
////    }
//
//    /**
//     * InputStream流转换成String字符串
//     * @param inStream InputStream流
//     * @param encoding 编码格式
//     * @return String字符串
//     */
//    public static String inputStream2String(InputStream inStream, String encoding){
//        String result = null;
//        try {
//            if(inStream != null){
//                ByteArrayOutputStream outStream = new ByteArrayOutputStream();
//                byte[] tempBytes = new byte[1024000];
//                int count = -1;
//                while((count = inStream.read(tempBytes, 0, 1024000)) != -1){
//                    outStream.write(tempBytes, 0, count);
//                }
//                tempBytes = null;
//                outStream.flush();
//                result = new String(outStream.toByteArray(), encoding);
//            }
//        } catch (Exception e) {
//            result = null;
//        }
//        return result;
//    }
//
//    //用户充值广告金
//    public void setBalanceMoney(String openid,double money){
//
//        logger.info("money==="+money);
//        String openId=openid;//前端测试
//        logger.info("openId==="+openId);
//        boolean bool= iUserService.rechargeRecord(openId,money);
//        logger.info("游戏充值成功！*************"+bool+"************");
//        logger.info("游戏充值成功！*******"+bool+"******************");
//        logger.info("游戏充值成功！************"+bool+"*************");
//        logger.info("游戏充值成功！********"+bool+"*****************");
//
//    }
//
//    //提现用户游戏币
////    @RequestMapping(value = "getCashBalance")
////    public JSONObject getCashBalance(HttpSession session){
////        User user=getTestUser(session);
////        synchronized (this) {
////            Balance balance = iMoneyService.getUserBalanceByOpenId(user.getOpenId());
////            if (balance.getMoney() < 1) {
////                return JSONUtils.getRoot(1,"fail","余额低于1元");
////            }
////            logger.info("===============提现金额为：" + balance.getMoney());
////            //String openId, double money, Timestamp createTime, int status
////            CashRegister cashRegister=new CashRegister(user.getOpenId(),balance.getMoney(),new Timestamp(new Date().getTime()),0);//提现记录
//////            balance.setMoney(0.0);
////            boolean bool = iMoneyService.updateBalanceByOpenId(balance);
////            if(bool){
////                iMoneyService.saveCashRegister(cashRegister);
////                return JSONUtils.getRoot(0,"success","提现成功");
////            }
////        }
////        return JSONUtils.getRoot(1,"fail","提现失败");
////    }
//
//    //提现用户佣金
////    @RequestMapping(value = "getCashComm")
//    public boolean getCashComm(HttpSession session){
//        User user=getTestUser(session);
//        synchronized (this) {
//            Commission commission = iMoneyService.getUserCommissionyByOpenId(user.getOpenId());
//            if (commission.getMoney() < 1) {
//                return false;
//            }
//            logger.info("===============提现金额为：" + commission.getMoney());
//            //String openId, double money, Timestamp createTime, int status
//            CashRegister cashRegister=new CashRegister(user.getOpenId(),commission.getMoney(),new Timestamp(new Date().getTime()),0);//提现记录
//            commission.setMoney(0.0);
//           boolean bool = iMoneyService.updateCommission(commission);
//            if(bool){
//                iMoneyService.saveCashRegister(cashRegister);
////                return JSONUtils.getRoot(0,"success","提现成功");
//                    return  bool;
//            }
//        }
//        return false;
//    }
//
//
//    /**
//     * 生成二维码
//     * @param session
//     * @return
//     */
//    @RequestMapping(value = "getQRCode",method = RequestMethod.GET)
//    public JSONObject getSubLevelCommission(HttpServletRequest request,HttpSession session) {
//        User userDO = (User) getSessionUser(request);
////        userDO=iUserService.getUserByUid(userDO.getId());
////        String openId=userDO.getOpenId();//前端测试
//        //userDO=iUserService.getUserByUid(2);
//        logger.info("====二维码==="+userDO.getQrCode().length());
//
//        String imgpath = GenerateImage(userDO.getQrCode(),request, String.valueOf(userDO.getId()));
//        if (imgpath==null){
//            return JSONUtils.getRoot(-1, "faild", "图片为空！");
//        }
//
//        return JSONUtils.getRoot(SUCCESS, "success", imgpath);
//    }
//
//    // 判断文件是否存在
//     public boolean judeFileExists(File file) {
//
//         if (file.exists()) {
////             System.out.println("file exists");
//             return true;
//         } else {
////             System.out.println("file not exists, create it ...");
////             try {
////                 file.createNewFile();
////             } catch (IOException e) {
////                 // TODO Auto-generated catch block
////                 e.printStackTrace();
////             }
//             return false;
//         }
//     }
//    //base64字符串转化成图片
//    private String GenerateImage(String imgStr,HttpServletRequest request,String userid)
//    {   //对字节数组字符串进行Base64解码并生成图片
//        if (imgStr == null) //图像数据为空
//            return null;
//        BASE64Decoder decoder = new BASE64Decoder();
//        try
//        {
//            //Base64解码
//            byte[] b = decoder.decodeBuffer(imgStr);
//            for(int i=0;i<b.length;++i)
//            {
//                if(b[i]<0)
//                {//调整异常数据
//                    b[i]+=256;
//                }
//            }
//            //生成jpeg图片 ,上传的目录地址
//            String imgFilePath= request.getSession().getServletContext().getRealPath("/")+"upload/user/img_qrcode/"+userid+".jpg";//新生成的图片
//            //生成jpeg图片 ,上传的目录地址
////            String imgFilePath = "D:\\360CloudUI\\tupian\\new.jpg";//新生成的图片
//
//            //为什么要注释掉？不判断是否有图片，无论有没有，都生成新的图片。
////            if (judeFileExists(new File(imgFilePath))){
////                return "/img_qrcode/"+userid+".jpg";
////            }
//
//            System.out.println(b.length+"==imgFilePath==="+imgFilePath);
//            System.out.println(b.length+"==imgFilePath==="+imgFilePath);
//            System.out.println(b.length+"==imgFilePath==="+imgFilePath);
//            OutputStream out = new FileOutputStream(imgFilePath);
//            out.write(b);
//            out.flush();
//            out.close();
//            return "upload/user/img_qrcode/"+userid+".jpg";
//        }
//        catch (Exception e)
//        {
//            return e.getMessage();
//        }
//    }
//
//    private static final String TRANSFERS_PAY = "https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers"; // 企业付款
//
//    @RequestMapping(value = "/updateAction",method = RequestMethod.POST)
//    @ResponseBody
//    public synchronized JSONObject updateAction(HttpServletRequest request,HttpServletResponse response){
//
////        logger.info("======进入updateAction======"+actionId+"==="+id);
////        if (actionId==2){
////            iWithdrawalService.updateAction(id,actionId);
////            logger.info("提现拒绝");
////            return JSONUtils.getRoot(0, "success", "提现拒绝");
////        }
////        User userDO = iUserService.getUserInfoById(uid);
//        //是否关闭微信支付功能
//        AliPaySwitch aliPaySwitch = iAdminUserService.getAliPaySwitch();
//        if (aliPaySwitch.getStatus()==0){
//            return JSONUtils.getRoot(3,"faild","提现时间段为参考公告！");
//        }
//
//        JSONObject returnjson = new JSONObject();
//        User userDO = (User)request.getSession().getAttribute(FootBall.FOOT_USER_SESSION);
//
//        //拉黑用户检测，并且拒绝其访问
//        List<BadUserDO> badUserDOList = iBadUserService.getBadUserByOpenid(userDO.getOpenId());
//        if (badUserDOList.size() > 0){
//            try {
//                response.sendRedirect(StaticValue.WX.NO_URL);
//            } catch (IOException e) {
//                e.printStackTrace();
//            }
//            returnjson = JSONUtils.getRoot(1,"faild","账户异常，暂不可提现！");
//            return returnjson;
//        }
//
//
//       long count= iCashRegisterDAO.getCountCashRecord(userDO.getOpenId());
//       if(count >= 3){
//           returnjson = JSONUtils.getRoot(4,"faild","今天提现次数为0！");
//           return returnjson;
//       }
//
//        int money = 0;
////        int upmoney = 0;
////        boolean result=  false;
////        synchronized(this)//这个对象可以为任意对象
////        {
//            //业务判断 openid是否有收款资格
//             money = (int) (iMoneyService.getUserCommissionyByOpenId(userDO.getOpenId()).getMoney() * 100);
//             //upmoney 是剩余可提现的金额
////             upmoney = (int) (iUserService.checkCashMoneyAmount(userDO.getOpenId()) * 100);
////             if (upmoney <=0){
////                 return JSONUtils.getRoot(2,"faild","今日提现额度已用完，请充值后提高提现额度后再操作");
////             }
////            double lastmoney = 0.0;
////            if(upmoney < money){
////                lastmoney = money - upmoney;
////                money = upmoney;
////            }
////             result=  iCommissionFootDAO.changeMoney(userDO.getOpenId(),lastmoney / 100);
////        }
//
//
//        System.out.println("提现金额"+money/100+"元！");
//        if (money < 100){
//            returnjson = JSONUtils.getRoot(1,"faild","提现金额不能小于1元！");
//        }
//        if (money >= 100 ){
//            logger.info("openid为："+userDO.getOpenId() + "的用户正在提现[/transfer/pay]");
//
//            String partner_trade_no =  PayUtil.getTransferNo();
//            String openid = userDO.getOpenId();
//            String amount =  String.valueOf(money);
//            String spbill_create_ip =  PayUtil.getLocalIp(request);
//            long userid = userDO.getId();
//            Date now = new Date();
//            Timestamp create_time = new Timestamp(now.getTime());
//
//            try {
//                Map<String, String> parm = new HashMap<String, String>();
//                parm.put("mch_appid", StaticValue.WX.AppId); //公众账号appid
//                parm.put("mchid", StaticValue.WX.MH_ID); //商户号
//                parm.put("nonce_str", PayUtil.getNonceStr()); //随机字符串
//                parm.put("partner_trade_no", partner_trade_no); //商户订单号
//                parm.put("openid", openid); //用户openid
//                parm.put("check_name", "NO_CHECK"); //校验用户姓名选项 OPTION_CHECK
//                //parm.put("re_user_name", "安迪"); //check_name设置为FORCE_CHECK或OPTION_CHECK，则必填
//                parm.put("amount", amount); //转账金额,单位：分
//                parm.put("desc", "转账到个人"); //企业付款描述信息
//                parm.put("spbill_create_ip", spbill_create_ip); //服务器Ip地址
//                parm.put("sign", PayUtil.getSign(parm, StaticValue.WX.APP_KEY));
//                String restxml = HttpUtils.posts(TRANSFERS_PAY, XmlUtil.xmlFormat(parm, false));
//
////                logger.info("restxml:"+restxml);
//                Map<String,String> maptemp = XMLBeanUtils.readStringXmlOut(restxml);
//
//                String returnCode = maptemp.get("return_code");
//                String resultCode = maptemp.get("result_code");
//                String returnMsg = "";
//                String errCodeDes = "";
//                String errCode = "";
//                String paymentNo = "";
//                String paymentTime = "";
//
//                logger.info("微信提现返回：");
//                logger.info("returnCode=="+returnCode);
//                logger.info("resultCode=="+resultCode);
//
//                if("SUCCESS".equals(returnCode) && "SUCCESS".equals(resultCode)){
//    //                iWithdrawalService.updateAction(id,actionId);
//
//                    returnMsg = maptemp.get("return_msg");
//                    paymentNo = maptemp.get("payment_no");
//                    paymentTime = maptemp.get("payment_time");
//
//                    logger.info("paymentTime:"+paymentTime);
//
//                    FbWxSuitcaseDO fbWxSuitcaseDO = new FbWxSuitcaseDO();
//                    fbWxSuitcaseDO.setOpenid(openid);
//                    fbWxSuitcaseDO.setAmount(amount);
//                    fbWxSuitcaseDO.setCreateTime(create_time);
//                    fbWxSuitcaseDO.setPartnerTradeNo(partner_trade_no);
//                    fbWxSuitcaseDO.setPaymentNo(paymentNo);
//                    fbWxSuitcaseDO.setPaymentTime(Timestamp.valueOf(paymentTime));
//                    fbWxSuitcaseDO.setReturnMsg(returnMsg);
//                    fbWxSuitcaseDO.setResultCode(resultCode);
//                    fbWxSuitcaseDO.setReturnCode(returnCode);
//                    fbWxSuitcaseDO.setSpbillCreateIp(spbill_create_ip);
//                    fbWxSuitcaseDO.setUserid(userid);
////                    iFbWxSuitcaseDAO.save(fbWxSuitcaseDO);
//                    iFbWxSuitcaseService.save(fbWxSuitcaseDO);
////                    String m = money + "";
////                    Double d1 = Double.parseDouble(m)/100;
//                    Double d2 = Double.parseDouble(String.valueOf(money))/100;
//                    //调用系统提现逻辑
////                    getCashBalance(request.getSession());
//                    getCashComm(request.getSession());
//                    logger.info("提现申请成功，提现金额为：" + d2);
//                    returnjson =  JSONUtils.getRoot(0, "success", "提现申请成功");
//                }else{
//                    returnMsg = maptemp.get("return_msg");
//                    errCodeDes = maptemp.get("err_code_des");
//                    errCode = maptemp.get("err_code");
////                    paymentNo = maptemp.get("payment_no");
////                    paymentTime = maptemp.get("payment_time");
//
//                    FbWxSuitcaseDO fbWxSuitcaseDO = new FbWxSuitcaseDO();
//                    fbWxSuitcaseDO.setOpenid(openid);
//                    fbWxSuitcaseDO.setAmount(amount);
//                    fbWxSuitcaseDO.setCreateTime(create_time);
//                    fbWxSuitcaseDO.setPartnerTradeNo(partner_trade_no);
////                    fbWxSuitcaseDO.setPaymentNo(paymentNo);
////                    fbWxSuitcaseDO.setPaymentTime(Timestamp.valueOf(paymentTime));
//                    fbWxSuitcaseDO.setReturnMsg(returnMsg);
//                    fbWxSuitcaseDO.setResultCode(resultCode);
//                    fbWxSuitcaseDO.setReturnCode(returnCode);
//                    fbWxSuitcaseDO.setSpbillCreateIp(spbill_create_ip);
//                    fbWxSuitcaseDO.setErrCode(errCode);
//                    fbWxSuitcaseDO.setErrCodeDes(errCodeDes);
//                    fbWxSuitcaseDO.setUserid(userid);
////                    iFbWxSuitcaseDAO.save(fbWxSuitcaseDO);
//                    iFbWxSuitcaseService.save(fbWxSuitcaseDO);
//
//                    logger.info("提现申请失败");
//                    returnjson =   JSONUtils.getRoot(-1,"faild","提现申请失败,请联系客服！");
//                }
//            } catch (Exception e) {
//                logger.error(e.getMessage(), e);
//                returnjson =   JSONUtils.getRoot(2,"faild",e.getMessage());
//            }
//        }
//        return returnjson;
//    }
//
//
//    /**
//     * 转动转盘获取奖励
//     * @return
////     */
////    @RequestMapping(value = "setTurntableRecord")
////    public synchronized JSONObject setTurntableRecord(HttpSession session,@RequestParam int site){
////
////
////        if(!(site==2 || site==5 || site==10 || site==20)){
////            return JSONUtils.getRoot(1,"faild","参数有误！");
////        }
////
////        User user= getTestUser(session);
////        if(user == null){
////            return JSONUtils.getRoot(1,"faild","用户不存在，重新登录！");
////        }
////
////        try{
////             Balance balance= iMoneyService.getUserBalanceByOpenId(user.getOpenId());
////             if(balance==null){
////                    return JSONUtils.getRoot(1,"faild","用户异常，请稍后重试");
////             }
////             if(balance.getMoney()<site){
////                 return JSONUtils.getRoot(1,"faild","用户余额不足");
////             }
//////            String nickName, String openId, long uid, String headImgUrl, long awardId, double amountBet, double amountMoney, Timestamp createTime ,String siteContent
//////            FbTurntableRecord turntableRecord=new FbTurntableRecord();//转盘记录
//////            turntableRecord.setUid(user.getId());
//////            turntableRecord.setNickName(user.getNickName());
//////            turntableRecord.setOpenId(user.getOpenId());
//////            turntableRecord.setHeadImgUrl(user.getHeadImgUrl());
//////            turntableRecord.setAmountBet(site);//下注金额
//////            turntableRecord.setCreateTime(new Timestamp(new Date().getTime()));
//////            turntableRecord.setSiteContent(site+"元场");
//////
//////            //获取可领取的奖励
//////            List<FbMissionAward> missionAwards = iMissionService.getMissionAwardStatus(site);
//////            if(missionAwards!=null) {
//////
//////                Random random = new Random();
//////                int result = random.nextInt(missionAwards.size());
//////                FbMissionAward missionAward = missionAwards.get(result);  //获取奖励信息
//////                turntableRecord.setAwardId(missionAward.getId());
//////                turntableRecord.setAmountMoney(missionAward.getAwardMoney());//中奖金额
//////                logger.info("此次转盘获得的奖励编号====================id:"+missionAward.getId()+"==========奖励金额money:"+missionAward.getAwardMoney());
//////            }else{
//////                //没有可领取的奖励信息
//////                turntableRecord.setAwardId(0);
//////                turntableRecord.setAmountMoney(0);//中奖金额
//////            }
//////            FbTurntableRecord record = iMissionService.saveFbTurntableRecord(turntableRecord);
////                if(record!=null){
////                    //修改用户余额
////                    balance.setMoney(balance.getMoney()-site);
////                    boolean bool=  iMoneyService.updateBalanceByOpenId(balance);
////                    if(bool){
////                        //添加用户支出记录
////                        //String openId, String expendType, double expendMoney, Timestamp expendTime
//////                        ExpendRecord expendRecord=new ExpendRecord(user.getOpenId(),"转盘"+record.getSiteContent(),record.getAmountBet(),new Timestamp(new Date().getTime()));
////                        //修改佣金
////                        Commission commission=iMoneyService.getUserCommissionyByOpenId(user.getOpenId());
////                        commission.setMoney(commission.getMoney()+record.getAmountMoney());
////                        bool=  iMoneyService.updateCommission(commission);
////                      if(bool){
////                          //String openId, String commissionType, double commissionMoney, Timestamp commissionTime
////                          //佣金记录
////                          CommissionRecord commissionRecord=new CommissionRecord(user.getOpenId(),"转盘奖励",record.getAmountMoney(),new Timestamp(new Date().getTime()));
////                          iMoneyService.saveCommissionRecord(commissionRecord);
////
////                          iUserService.addAgencyComm(user.getOpenId(),record.getAmountBet());//使用转盘之后返佣
////
////                          JSONObject jsonObject=new JSONObject();
////                          jsonObject.put("amountMoney",record.getAmountMoney());
////                          jsonObject.put("commMoney",commission.getMoney());
////                          jsonObject.put("money",balance.getMoney());
////
////
////                          return JSONUtils.getRoot(0, "success", jsonObject);
////                      }
////                    }
////                }
////
////            return JSONUtils.getRoot(1, "faild", null);
////        }catch (NullPointerException e){
////            return JSONUtils.getRoot(1,"faild","用户异常，请稍后重试");
////        }
////
////    }
//
//
//    public User getTestUser(HttpSession session){
//        User user = (User) session.getAttribute(FootBall.FOOT_USER_SESSION);
////        User user=iUserService.getUserByUid(1);
//        return user;
//    }
//
//    /**
//     * 获取session中的用户信息
//     * @param request
//     * @return
//     */
//    public User getSessionUser(HttpServletRequest request){
////        User user = new User();
////        user.setOpenId("dfgir4339fm2p30109cm32fn3293");
////        user.setNickName("你大爷");
////        user.setHeadImgUrl("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1505803896095&di=778f0d126297b0d0a208acec354503b0&imgtype=0&src=http%3A%2F%2Fimg1.skqkw.cn%3A888%2F2013%2F06%2F17%2F201306171802421285.jpg");
////        user.setId(1L);
////        user.setQrCode("iVBORw0KGgoAAAANSUhEUgAAASwAAAEsCAIAAAD2HxkiAAAGjElEQVR42u3cQXblIBADQN//0skh\n" +
////                "/kOthtLaE2zoIgu9yfcnIqP5bIEIhCIQigiEIhCKCIQiEIoIhCIQigiEIhCKCIQiEIoIhCIQigiE\n" +
////                "IhCKCIQiEIpIKcKvLz++fG7fD3xR7Ixiq983dRBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQHkQ4\n" +
////                "O8cnJj52GLOb7PacWh1CCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQwgoGP/7M2MwV7tJsKXfi2++b\n" +
////                "OgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEII30JYuO/DxdQSmRBCCCGEEEIIIYQQQgghhBBCCCGE\n" +
////                "EEIIIYQQQvjMdox2eoWKtrw8hBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQrvlra7EKa3WrFisk\n" +
////                "n65tIYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCEMb3GsrfLk9U8WTh2ERhZCCCH0JIQQGlkIIYTQ\n" +
////                "kxBCaGQhhBBCT0J4EOHLKSy7CmduS/s3PEs4QQghhBBCCKFACCGEEEIIoUAIIYQQQgjhrlNf3T3m\n" +
////                "OqjUcL9cXUIIIYQQQgghhBBCCCGEEEIIIYQQQgghhBBC2NsTzs5cbPWYjdl/HpMZu6Zntw5CCCGE\n" +
////                "EEIIIYQQQgghhBBCCCGEEEIIIYQQwoqZiykqPMst98LsGd1XHkIIIYQQQgghhA4YQgghhBBCCB0w\n" +
////                "hBBCCCGEEKYrwS27WdjpzWb2Cthyg0AIIYQQQgghhBBCCCGEEEIIIYQQQgghhBBCeBBhYX0Xm+PY\n" +
////                "VZVrq/p2fsulBiGEEEIIIYQQQgghhBBCCCGEEEIIIYQQQgjhsp5wdotn69DCUu6+XZr9JQEhhHYJ\n" +
////                "QgghhBBCCCGEEEIIIYQQQgghhBBCCCsQzjY2W4a7sP3boqjw5SGEEEIIIYQQQgghhBBCCCGEEEII\n" +
////                "IYQQQgghvAFhrJgqrNpW31+FCzWeJoQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEYW8vj9cWrrE6\n" +
////                "9L5XghBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYSwAuEWw3+pzA5N4YZsOXcIIYQQQgghhBBCCCGE\n" +
////                "EEIIIYQQQgghhBBCCK/tCWMjG1t9dXE6q/2RqwpCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQwt6e\n" +
////                "sLBuOmF49q6Zvb9mZ2m2OIUQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEMD3xse5xy3A/stBqhHU9\n" +
////                "IYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCOGbCLf0hLON4mwHVThzhU3d7NBCCCGEEEIIIYQQQggh\n" +
////                "hBBCCCGEEEIIIYQQQtjxQgfmY3UpFys5v1S2fHsONoQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGE\n" +
////                "uxBuGdlZroW12Jb6DkIIIYQQQgghhBBCCCGEEEIIIYQQQgghhBDCXoQn9mi2rdK/9X/7CYSxnYcQ\n" +
////                "QgghhBBCCCGEEEIIIYQQQgghhBBCCCGEUE+Y2+LCrZu1sVqmsh5CCCGEEEIIIYQQQgghhBBCCCGE\n" +
////                "EEIIIYTwBoSzB9zYF/WVh7HTjHXOsSchhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIbwW4X2vVFiH\n" +
////                "Fn77lsoaQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEMIKhF8qsUKysOyavVYKh2FNPwwhhBBCCCGE\n" +
////                "EEIIIYQQQgghhBBCCCGEEEII4a2ZLZEeqUO3nFHjz4QQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGE\n" +
////                "sGEQC3vC2HDH+szZDdny5OKyHkIIIYQQQgghhBBCCCGEEEIIIYQQQgghhPBNhI80S4+0f7Ej3tLp\n" +
////                "Hfl2CCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQQggbRnZLC2T1gPbZJhlCDCCEEEKrQwghBhBCCKHV\n" +
////                "IYQQAwghhNDqEEK45n/uFLaUs9MZe88tVTCEEEIIIYQQQgghhBBCCCGEEEIIIYQQQgghhBB+WwzP\n" +
////                "LlSoKPZFseOAEEIIIYQQQgghhBBCCCGEEEIIIYQQQgghhLB3PgoRxt7zxMytfvkYrdz1ByGEEEII\n" +
////                "IYQQQgghhBBCCCGEEEIIIYQQQghhbbO0RdHqG2RWUeF+5l4eQgghhBBCCCGEEEIIIYQQQgghhBBC\n" +
////                "CCGEEEIRyQdCEQhFIBQRCEUgFBEIRSAUEQhFIBQRCEUgFBEIRSAUEQhFIBQRCEUgFBEIRSAUEQhF\n" +
////                "7s0/So5S7WXUXY0AAAAASUVORK5CYII=");
//        User user = (User) request.getSession().getAttribute(FootBall.FOOT_USER_SESSION);
//        return user;
//    }
//
//}
//
//
//
//
//
//
//
//
//
//
//
//
//
